<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<input type="button" value="帅哥" onclick="f(1)">
<input type="button" value="美女" onclick="f(2)">
<hr>
<script>
    function f(x){
        //也可以用三目来赋值src
        let i = document.createElement("img");
        switch (x){
            case 1:
                i.src = "../a.jpg"
                break;
            case 2:
                i.src = "../b.jpg"
                break;
        }
        document.body.append(i);
    }

</script>
</body>
</html>